import { defineStore } from 'pinia'

const useLocaleStore = defineStore('locale', {
  state: () => {
    return {
      LOCALE_MAP: {
        'zh-CN': 'zh-CN',
        en: 'en'
      },
      currentLocale: navigator.language
    }
  },
  getters: {},
  actions: {
    setCurrentLocale(l) {
      this.currentLocale = this.LOCALE_MAP[l]
    }
  },
  // 持久化存储
  persist: {
    storage: window.localStorage
  }
})

export { useLocaleStore }
